/**
 * @version 1.8
 * @Author Djx_hmbb
 * @Date 2023/8/11 21:00
 * @注释:查看NEW/TIMED-WAITING/TERMINATED的状态
 */
public class ThreadDemo10 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("hello main");
        });
        System.out.println("运行前t的状态:" + t.getState());//查看start前的状态
        t.start();

        //循环查看状态
        for (int i = 0; i < 100; i++) {
            System.out.println("运行中t的状态:" + t.getState());
        }

        //查看结束的状态
        try {
            t.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("运行后t的状态:" + t.getState());


    }
}
